00001
00002
00003
00004
00005
00006
00007
00011 class BuildingN {
00012
00016 public:
00017 void NewBuilding(int buildingId, int roofId, int size, int xpos, int zpos, int buildingTexture, int roofTexture) {
00018
00019 dbRandomize(dbTimer());
00020
00021 dbMakeObjectCube(buildingId, size);
00022 dbTextureObject(buildingId ,buildingTexture);
00023 dbPositionObject(buildingId, xpos, 0 , zpos);
00024 dbMakeObjectPlane(roofId, size, size);
00025 dbRotateObject(roofId, 90, 0, 0);
00026
00027 dbPositionObject(roofId, xpos, (size / 2 ) + .7 , zpos);
00028 dbTextureObject(roofId,roofTexture);
00029
00030 }
00031 };
00032
00036 class MusicPlayer {
00037 private:
00038 int musicMode;
00039 public:
00040
00041 void loop() {
00046
00047
00048 if (musicMode ==2 && dbMusicPlaying(m_death)==0)
00049 {
00050 dbStopMusic(m_combat);
00051 dbStopMusic(m_idle);
00052 changeMusic(m_death);
00053 }
00054
00055
00056 if (musicMode ==3 && dbMusicPlaying(m_title)==0)
00057 {
00058 dbStopMusic(m_combat);
00059 dbStopMusic(m_idle);
00060 changeMusic(m_title);
00061 }
00062
00063 if (musicMode ==1 && dbMusicPlaying(m_combat)==0)
00064 {
00065 dbStopMusic(m_idle);
00066 changeMusic(m_combat);
00067 }
00068 if (musicMode ==0 && dbMusicPlaying(m_idle)==0)
00069 {
00070 dbStopMusic(m_combat);
00071 changeMusic(m_idle);
00072 }
00073 musicMode=0;
00074
00075
00076
00077 }
00078
00082 void play(int mode) {
00083 musicMode= mode;
00084 }
00085
00089 int getMode() {
00090 return musicMode;
00091 }
00092
00096 void changeMusic(int music) {
00097 for (int xx=0; xx<4; xx++)
00098 {
00099 if (dbMusicLooping(xx)==1) dbStopMusic(xx);
00100 dbLoopMusic(music);
00101 }
00102
00103 }
00104
00105
00106 };
00107
00112 class Vehicle {
00113 public:
00114
00115
00116
00117 int NewVehicle(int team, int type) {
00122 int x= vehicleNumStart;
00123 int moveable=0;
00124 if (type == 31 || type == 32 || type == 50 || type == 52 || type ==60 || type ==62)
00125 moveable= 0;
00126
00127 if (type == 34 || type == 36 || type == 54 || type == 56)
00128 moveable= 1;
00129
00130
00131 for (x=vehicleNumStart; x< vehicleNumEnd+1; x++) {
00132 if (dbObjectExist(x) ==0) break;
00133 }
00134
00135 if (x< vehicleNumEnd) {
00136 O[x][TM]= team;
00137
00138 O[x][MOVEABLE]=moveable;
00139
00140 if (team==gold) {
00141
00142 if (moveable ==1) {
00143
00144 if (type == 34) {
00145 dbLoadObject("TANK1.x",x);
00146
00147
00148
00149 O[x][ML]=10;
00150
00151 }
00152
00153 if (type == 36) {
00154 dbLoadObject("TANK1.x",x);
00155
00156
00157
00158
00159
00160 dbScaleObject(x, 200,100,100);
00161
00162 O[x][ML]=60;
00163
00164
00165 }
00166
00167
00168
00169
00170
00171
00172
00173 O[x][L]=O[x][ML];
00174 }
00175
00176
00177 if (moveable ==0) {
00178 if (type == 31) {
00179 dbMakeObjectCube(x,10);
00180
00181
00182 dbColorObject(x, dbRGB(0,0,25));
00183
00184
00185 O[x][ML]=20;
00186
00187 }
00188
00189
00190 if (type == 32) {
00191 dbMakeObjectCube(x,20);
00192 dbColorObject(x, dbRGB(0,0,100));
00193
00194
00195 O[x][ML]=100;
00196 }
00197
00198
00199 O[x][L]=O[x][ML];
00200 }
00201 }
00202
00203
00205 if (team==red) {
00206
00207 if (moveable ==1) {
00208
00209 if (type == 34) {
00210 dbLoadObject("TANK5.x",x);
00211
00212
00213 O[x][ML]=10;
00214
00215 }
00216
00217 if (type == 36) {
00218 dbLoadObject("TANK5.x",x);
00219 dbColorObject(x, dbRGB(250,100,0));
00220
00221 O[x][ML]=30;
00222 }
00223
00224 dbScaleObject(x, 100,100,100);
00225
00226
00227
00228
00229
00230 O[x][L]=O[x][ML];
00231 }
00232 if (moveable ==0) {
00233
00234
00235 if (type == 50) {
00236 dbMakeObjectSphere(x,100);
00237
00238
00239 dbColorObject(x, dbRGB(50,0,0));
00240
00241 }
00242
00243
00244 if (type == 32) {
00245 dbMakeObjectSphere(x,200);
00246 dbColorObject(x, dbRGB(0,0,200));
00247
00248 }
00249
00250
00251 dbScaleObject(x, 10,10,10);
00252
00253
00254
00255 O[x][ML]=30;
00256 O[x][L]=O[x][ML];
00257 }
00258
00259 }
00260
00261
00262
00263 dbYRotateObject(x,180);
00264 dbFixObjectPivot(x);
00265
00266
00267
00268 if (O[x][TM] == player) {
00269 alliesLeft++;
00270 dbPositionObject(x,dbRND(100)-50,0,dbRND(100)-50);
00271 }
00272
00273 if (O[x][TM] != player) {
00274 enemiesLeft++;
00275 dbPositionObject(x,dbRND(250)+50,0,dbRND(250)+50);
00276 }
00277
00278 if (type == 60) {
00279 dbMakeObjectSphere(x,100);
00280
00281
00282
00283
00284 dbScaleObject(x, 1000,1000,1000);
00285
00286 dbTextureObject(x,1000);
00287 O[x][ML]=300;
00288 O[x][L]=O[x][ML];
00289 dbPositionObject(x,0,0,-50);
00290 }
00291
00292 if (type == 62) {
00293
00294 dbMakeObjectSphere(x,100);
00295
00296
00297 dbScaleObject(x, 1000,1000,1000);
00298
00299 dbTextureObject(x,1000);
00300 O[x][ML]=300;
00301 O[x][L]=O[x][ML];
00302 dbPositionObject(x,200,0,200);
00303 }
00304
00305
00306
00307 O[x][PER]= dbRND(1);
00308
00309 O[x][DX]= dbObjectPositionX(x);
00310 O[x][DZ]= dbObjectPositionZ(x);
00311
00312 O[x][AR]=100;
00313
00314 return x;
00315 }
00316 else
00317 return 0;
00318 }
00319
00320
00321
00322 int isVehcile(int id) {
00326 if (id >= vehicleNumStart && id <= vehicleNumEnd)
00327 return 1;
00328 else
00329 return 0;
00330
00331 }
00332
00333
00334 };
00335
00336
00337
00343 class planeEnv {
00344 public:
00345
00346
00347 void newTourPlane(int id) {
00352 int pick=dbRND(1);
00353
00354 if (pick==0) {
00355 dbLoadObject("AIRPL011.x",id);
00356 dbScaleObject(id,300,300,300);
00357 }
00358 if (pick==1) {
00359 dbLoadObject("AIRPL016.x",id);
00360 dbYRotateObject(id,180);
00361 dbFixObjectPivot(id);
00362
00363 }
00364
00365 dbRandomize(dbTimer());
00366 dbYRotateObject(id,dbRND(360));
00367 O[id][SL]= dbRND(30)*.1+3;
00368 O[id][RL]= (dbRND(5)*.1 +.05) * (1-dbRND(2)) +.01;
00369
00370 dbPositionObject(id,dbRND(1000)-500,dbRND(20)+50,dbRND(1000)-500);
00371
00372 }
00373
00374
00375 };
00376
00377
00378
00379
00380
00381
00386 class SoundPlayer {
00387 private:
00388 int soundMode;
00389 public:
00390
00395 void loop() {
00396
00397 if (soundMode ==2 && dbSoundPlaying(m_death)==0)
00398 {
00399 dbStopSound(m_combat);
00400 dbStopSound(m_idle);
00401 changeSound(m_death);
00402 }
00403
00404
00405 if (soundMode ==3 && dbSoundPlaying(m_title)==0)
00406 {
00407 dbStopSound(m_combat);
00408 dbStopSound(m_idle);
00409 changeSound(m_title);
00410 }
00411
00412 if (soundMode ==1 && dbSoundPlaying(m_combat)==0)
00413 {
00414 dbStopSound(m_idle);
00415 changeSound(m_combat);
00416 }
00417 if (soundMode ==0 && dbSoundPlaying(m_idle)==0)
00418 {
00419 dbStopSound(m_combat);
00420 changeSound(m_idle);
00421 }
00422 soundMode=0;
00423 }
00429 void play(int mode) {
00430 soundMode= mode;
00431 }
00432
00437 int getMode() {
00438 return soundMode;
00439 }
00440
00445 void changeSound(int sound) {
00446 for (int xx=0; xx<4; xx++)
00447 {
00448 if (dbSoundLooping(xx)==1) dbStopSound(xx);
00449 dbLoopSound(sound);
00450 }
00451
00452 }
00453
00454
00455 };
00456
00457
00458
00463 class AI {
00464
00465 public:
00466
00471 void newAI() {
00472 int xx=6;
00473 int loopout2=0;
00474 for (int yy= vehicleNumStart; yy< vehicleNumEnd && loopout2==0; yy++) {
00475 if (O[xx][TM] != O[yy][TM]
00476 && O[yy][L]>=0
00477 && dbSqrt( pow((O[xx][X] - O[xx][DX]),2)
00478 + pow((O[xx][Z] - O[xx][DZ]),2) )<5
00479 && O[xx][ET]==0
00480 && withinRange(xx,yy,200) ==1) {
00481
00482
00483 if ((withinRange(xx,yy,100) ==0)
00484 && (withinRange(xx,yy,150) ==1)
00485 && O[xx][ET]==0)
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496 dbPointObject(xx, O[yy][X],0,O[yy][Z]);
00497
00498
00499 loopout2=1;
00500
00501
00502 }
00503
00504 }
00505
00506
00507
00508 }
00509 };
00510
00511
00516 class AddEnv {
00517
00518 public:
00519
00524 void addEnv() {
00525
00526 dbLoadImage(
00527 "building1.bmp", 30005);
00528
00529 dbLoadImage(
00530 "building1roof.bmp", 30007);
00531
00532 dbLoadImage(
00533 "building2.bmp", 30008);
00534
00535 dbLoadImage(
00536 "building2roof.bmp", 30009);
00537
00538 dbLoadImage(
00539 "building300.bmp", 30010);
00540
00541 dbLoadImage(
00542 "building300roof.bmp", 30011);
00543
00544 dbLoadImage(
00545 "building4.bmp", 30012);
00546
00547 dbLoadImage(
00548 "building4roof.bmp", 30013);
00549
00550 int builTex[6];
00551
00552 builTex[0] = 30005;
00553
00554 builTex[1] = 30005;
00555
00556 builTex[2] = 30008;
00557
00558 builTex[3] = 30010;
00559
00560 builTex[4] = 30012;
00561
00562 builTex[5] = 30012;
00563
00564 int roofTex[6];
00565
00566 roofTex[0] = 30007;
00567
00568 roofTex[1] = 30007;
00569
00570 roofTex[2] = 30009;
00571
00572 roofTex[3] = 30011;
00573
00574 roofTex[4] = 30013;
00575
00576 roofTex[5] = 30013;
00577
00578
00579
00580 dbLoadImage("ground.jpg",10000);
00581
00582 dbLoadImage("road.bmp", 3);
00583
00584 dbMakeMatrix(1,3000,3000,10,10);
00585
00586 dbRandomizeMatrix(1,3);
00587
00588
00589
00590 dbPositionMatrix(1,-500,-10,-500);
00591
00592 dbPrepareMatrixTexture(1,10000,1,1);
00593
00594
00595 }
00596 };
00597
00598
00599
00604 class Map {
00605
00606 public:
00607
00608 void newMap() {
00614 dbLoadImage("ground.jpg",10000);
00615
00616 dbLoadImage("road.bmp", 3);
00617
00618 dbMakeMatrix(1,3000,3000,10,10);
00619
00620 dbRandomizeMatrix(1,3);
00621
00622
00623
00624 dbPositionMatrix(1,-500,-10,-500);
00625
00626 dbPrepareMatrixTexture(1,10000,1,1);
00627
00628
00629 }
00630 };
00631
00632
00633
00634